namespace CSharpPro._1028;

public class User
{
    private int id;
    
    

    public int Id
    {
        get => id;
        set => id = value;
    }

    public void Show()
    {
        Console.WriteLine("show-----------------");
    }
    
    
    private string _username;  // 用户名（唯一标识）
    private string _password;  // 密码
    private string _email;     // 邮箱
    
    public User()
    {
    }
    
    public User(string username, string password, string email)
    {
        _username = username;
        _password = password;
        _email = email;
    }
    
    public string Username
    {
        get => _username;
        set 
        { 
            // 简单数据校验：用户名不能为空
            if (string.IsNullOrWhiteSpace(value))
                throw new ArgumentException("用户名不能为空或空格！");
            _username = value; 
        }
    }

    public string Password
    {
        get => _password;
        set 
        { 
            // 简单数据校验：密码长度不小于6位
            if (string.IsNullOrWhiteSpace(value) || value.Length < 6)
                throw new ArgumentException("密码不能为空且长度不小于6位！");
            _password = value; 
        }
    }

    public string Email
    {
        get => _email;
        set 
        { 
            // 简单数据校验：邮箱格式（含@符号）
            if (!string.IsNullOrWhiteSpace(value) && !value.Contains("@"))
                throw new ArgumentException("邮箱格式不正确（需包含@符号）！");
            _email = value; 
        }
    }
}